
//
//  NotificationTableViewCell.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/16.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "NotificationTableViewCell.h"

@interface NotificationTableViewCell ()
{
    UILabel * contentLabel;
    UILabel * timeLabel;
    UIButton * accept;
    UIButton * denile;
    
    NSDictionary * contentDic;
}
@end

@implementation NotificationTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth - 160, 20)];
        contentLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:contentLabel];
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth - 150, 10, 45, 20)];
        timeLabel.numberOfLines = 2;
        timeLabel.font = [UIFont systemFontOfSize:7];
        [self addSubview:timeLabel];
        
        accept = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 100, 10, 45, 20)];
        accept.layer.borderColor = [UIColor orangeColor].CGColor;
        accept.layer.borderWidth = 1;
        [accept setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
        accept.titleLabel.font = [UIFont systemFontOfSize:10];
        [accept setTitle:@"接受" forState:UIControlStateNormal];
        accept.layer.cornerRadius = 10;
        [accept addTarget:self action:@selector(acceptAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:accept];
        
        denile = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - 50, 10, 45, 20)];
        denile.layer.borderColor = [UIColor orangeColor].CGColor;
        denile.layer.borderWidth = 1;
        [denile setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
        denile.titleLabel.font = [UIFont systemFontOfSize:10];
        [denile setTitle:@"拒绝" forState:UIControlStateNormal];
        denile.layer.cornerRadius = 10;
        [denile addTarget:self action:@selector(denileAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:denile];
    }
    return self;
}

+(CGFloat)height
{
    return 40;
}

-(void)acceptAction
{
    [self.delegate acceptAction:contentDic];
}

-(void)denileAction
{
    [self.delegate denileAction:contentDic];
}

-(void)loadData:(NSDictionary *)data
{
    contentDic = data;
    contentLabel.text = [data objectForKey:@"Content"];
    if (![[data objectForKey:@"AppFriendId"]isKindOfClass:[NSNull class]])
    {
        timeLabel.frame = CGRectMake(ScreenWidth - 150, 10, 45, 20);
        timeLabel.text = [data objectForKey:@"Time"];
        accept.hidden = NO;
        denile.hidden = NO;
    }
    else
    {
        timeLabel.frame = CGRectMake(ScreenWidth - 50, 10, 45, 20);
        timeLabel.text = [data objectForKey:@"Time"];
        accept.hidden = YES;
        denile.hidden = YES;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
